package datatypes;

import java.util.ArrayList;
import java.util.List;

public class Soldier implements Comparable<Soldier> {

	private static int globalId = 0;
	private int id;
	public String name;
	public String lastName;
	public double dPoints;
	public List<Duty> duties;

	public Soldier() {
		setId(++globalId);
		this.name = "";
		this.lastName = "";
		dPoints = 0;
		duties = new ArrayList<Duty>();
	}

	public Soldier(String name, String lastName) {
		setId(++globalId);
		this.name = name;
		this.lastName = lastName;
		dPoints = 0;
		duties = new ArrayList<Duty>();
	}

	public String getName() {
		return this.name;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getLastName() {
		return this.lastName;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getdPoints() {
		return this.dPoints;
	}

	public void setdPoints(double dPoints) {
		this.dPoints = dPoints;
	}

	public void addDuty(Duty duty) {
		this.duties.add(duty);
		this.dPoints += duty.getTotalPoints();
	}

	public void removeDuty(Duty duty) {
		this.duties.remove(duty);
	}

	@Override
	public int compareTo(Soldier another) {
		return (int) (this.dPoints - another.dPoints);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Override
	public String toString() {

		return this.id + " : " + this.name + " " + this.lastName + " dpoints: " + dPoints;
	}

}
